package com.example.lt.util;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.Data;

import java.text.MessageFormat;

/**
 * @Author 小涛Tao
 * @Date: 2024/07/27/15:17
 * version 1.0 注释：
 **/
@Data
public class Result<T> {

    private static final long serialVersionUID = 22L;

    private T type;

    private int code;

    private Boolean state;

    private String message;

    private Object data;

    private long count;

    public Result() {}

    public static Result ok() {
        Result result = new Result();
        result.setCode(0);
        result.setState(true);
        result.setMessage("成功");
        return result;
    }

    public static Result error() {
        Result result = new Result();
        result.setCode(201);
        result.setState(false);
        result.setMessage("失败");
        return result;
    }

    public Result count(long count) {
        this.setCount(count);
        return this;
    }

    public Result message(String message){
        this.setMessage(message);
        return this;
    }

    public Result data(Object resData){
        this.setData(resData);
        return this;
    }

}
